<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meat name="viewpoet" content="with=device-width, initial-scale=1.0">
        <title>Document</title>
</head>

<body>
    <div id="app">
        <h3>v-methods修饰符 .trim .number</h3>
        <!-- trim 修剪  username前后的空格会被删掉 -->
        姓名：<input v-model.trim="username" type="text"><br>
        <!-- number  age会被解析成number(数字) 而不是字符串 -->
        年龄：<input v-model.number="age" type="text"><br>

        <h3>@事件名.stop -> 阻止冒泡</h3>
        <!-- 这里点击儿子，也会alert(父亲)  如何阻止冒泡？ .stop -->
        <div @click="fatherFn" class="father">
            <div @click.stop="sonFn" class="son">儿子</div>
        </div>

        <h3>@事件名.prevent -> 阻止默认行为</h3>
        <!-- prevent 防止，阻止 -->
        <a @click.prevent href="http://www.baidu.com">阻止默认行为</a>
    </div>
    <!-- 引入的是开发版本包 - 包含完整的注释和警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.16/dist/vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                username: '',
                age: ''
            },
            methods: {
                fatherFn() {
                    alert('老父亲被点击了！')
                },
                sonFn() {
                    //e.stopPropagation()
                    alert('儿子被点击了！')
                }
            }
        })
    </script>

</body>

</html>